$(function () {
    vm.loadInfo();
});
var vm = new Vue({
    el: '#rrapp',
    data : {
        totalDish : 0,
        tasteFavor : {},
        originalityFavor :{},
        exteriorFavor:{},
        tasteRes : [],
        exteriorRes : [],
        originalityRes : [],
        dish : {
            table : -1
        },
        score : {
            dishId : '',
            raterTable : ''
        },
        removeDishMsg : '',
        removeScoreMsg : '',
        msg : ''
    },
    methods: {
        loadInfo : function () {
            $.ajax({
                url: "../admin/info?t=" + $.now(),
                type: 'get',
                success : function (result){
                    vm.totalDish = result.totalDish;
                    vm.tasteFavor = result.tasteFavor;
                    vm.originalityFavor = result.originalityFavor;
                    vm.exteriorFavor = result.exteriorFavor;
                    vm.tasteRes = result.tasteRes;
                    vm.exteriorRes = result.exteriorRes;
                    vm.originalityRes = result.originalityRes;
                },
                complete:function(){
                    vm.loadInfo();
                }
            });
        },
        removeDish : function () {
            $.ajax({
                url: "../admin/removeDish",
                type: 'post',
                contentType:"application/json;charset=UTF-8",
                data : JSON.stringify(vm.dish),
                success : function (result) {
                    vm.removeDishMsg = result.msg;
                    alert(result.msg);
                }
            });
        },
        removeScore : function () {
            $.ajax({
                url: "../admin/removeDish",
                type: 'post',
                contentType:"application/json;charset=UTF-8",
                data : JSON.stringify(vm.score),
                success : function (result) {
                    vm.removeScoreMsg = result.msg;
                    alert(result.msg);
                }
            });
        },
        removeSys : function () {
            $.ajax({
                url: "../admin/removeAll",
                type: 'post',
                contentType:"application/json;charset=UTF-8",
                success : function (result) {
                    vm.msg = result.msg;
                    alert(result.msg);
                }
            });
        }
    }
});